<template>
  <div>
    <Practice
      v-for="(item, index) in arr"
      :key="index"
      :src="item.dogImgUrl"
      :title="item.dogName"
      @doge="selBtn"
      :index="index"
    />
    <h2>您喜欢的狗如下:</h2>
    <ul>
      <li v-for="(item, index) in str" :key="index">
        {{ item }}
      </li>
    </ul>
  </div>
</template>

<script>
import Practice from './components/Practice2.vue'
export default {
  data() {
    return {
      arr: [
        {
          dogImgUrl:
            'http://nwzimg.wezhan.cn/contents/sitefiles2029/10146688/images/21129958.jpg',
          dogName: '博美',
        },
        {
          dogImgUrl:
            'https://img2.baidu.com/it/u=976818361,3220766396&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=346',
          dogName: '泰迪',
        },
        {
          dogImgUrl:
            'https://img0.baidu.com/it/u=3568744664,1377462273&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=625',
          dogName: '金毛',
        },
        {
          dogImgUrl:
            'https://pic1.zhimg.com/80/v2-7ba4342e6fedb9c5f3726eb0888867da_1440w.jpg?source=1940ef5c',
          dogName: '哈士奇',
        },
        {
          dogImgUrl:
            'https://img0.baidu.com/it/u=785702198,2527104588&fm=253&fmt=auto&app=138&f=JPEG?w=270&h=270',
          dogName: '阿拉斯加',
        },
        {
          dogImgUrl:
            'https://img0.baidu.com/it/u=359481618,4261037644&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
          dogName: '萨摩耶',
        },
      ],
      str: [],
    }
  },
  components: {
    Practice: Practice,
  },
  methods: {
    selBtn(index) {
      console.log(this.str)
      this.str.push(this.arr[index].dogName)
    },
  },
}
</script>

<style></style>
